package rds

import (
	"github.com/go-redis/redis"
	"logagent/utils"
)

var (
	rds *redis.Client
)

func Init(host string, db int, password string) {
	client := redis.NewClient(&redis.Options{
		Addr:     host,
		DB:       db,
		Password: password,
	})
	_, err := client.Ping().Result()
	if err != nil {
		utils.Fatalf("ping redis failed , err: %s", err.Error())
	}
	rds = client
}

func GetRds() *redis.Client {
	return rds
}
